﻿using System;
using System.ComponentModel;
using System.Windows;

namespace OpenLightGroup.Common
{
    /// <summary>
    /// Helper class to make DesignTime / RunTime code a little cleaner.
    /// </summary>
    public static class DesignTimeHelper
    {
        private static bool? _isInDesignModeStatic;

        /// <summary>
        /// Is the code currently executing in a designer
        /// </summary>
        public static bool IsInDesignMode
        {
            get
            {
                if (!_isInDesignModeStatic.HasValue)
                {
                    _isInDesignModeStatic = DesignerProperties.IsInDesignTool;
                }

                return _isInDesignModeStatic.Value;
            }
        }

        /// <summary>
        /// Is the code currently executing in an application
        /// </summary>
        public static bool IsRuntime
        {
            get { return !IsInDesignMode; }
        }
    }
}
